<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件上传</title>
<link type="text/css" rel="stylesheet" href="/css/upload/show_book.css"/>
<script type="text/javascript" language="JavaScript" src="/js/upload/show_book.js"></script>
<style type="text/css">
.des{
	background-image: url("/image/head/searh_backgroud_shadow.gif");
	padding-top: 5px;
	padding-bottom: 5px;
	font-size: 16px;
	color: blue;
	font-weight: bold;
	margin-bottom: 5px;
}
.send{
	background-color:gray;
	background-image: url("/image/head/searh_backgroud.gif");
	width: 50xp;
	font-size: 16px;
	color: blue;
	font-weight: bold;
}
</style>
<script type="text/javascript">
function checkfm(){
	var file=document.getElementById("filePath").value;
	if(file!=""){
		var types = ["shg","txt","xml","pdf"];
		var ext = file.substring(file.lastIndexOf('.')+1,file.length).toLowerCase();
		var sing = false;
		for(var i=0; i<types.length;i++){
			if (ext==types[i]){
				sing = true; 
			}
		}
		if(!sing){
			alert("只允许上传shg,txt,xml,pdf格式的书籍");
		}else{
			document.getElementById("formFile").submit();
		}
		return 	sing;	
	}else{
		alert("请选择上传的书籍");
	}
	return false;
}
function showBook(url,div){
		var xmlhttp;
		if(window.XMLHttpRequest) {
			// 如果是 IE7+, Firefox, Chrome, Opera, Safari这些浏览器将会以下面这张方式创建
			xmlhttp = new XMLHttpRequest();
		} else {
			// 如果是 IE6, IE5将会以下面的两种方式创建
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				//如果小于等于0就说明里面还没有内容，这时候就需要说明可能是第一次切换到该界面需要到数据库查询书籍
				document.getElementById(div).innerHTML =  xmlhttp.responseText;
			}
		}
		xmlhttp.open("GET", url, true);
		xmlhttp.send();
	}
</script>
</head>
<body onload="showBook('/control/book/upload_showBook.go','showBook')">
<center>
	<form id="formFile" 
		action="${pageContext.request.contextPath}/control/book/upload_uploadBook.go" 
		method="post" enctype="multipart/form-data">
		<div class="des">只允许上传shg格式书籍</div>
		本地文件：<input class="send" type="file" name="upload" id="filePath"><br/>
		<input class="send" type="button" value="确  定" onclick="checkfm()">
	</form>
</center>
<div id="showBook"></div>
</body>
</html>